package org.chen.common;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("user_with_chat")
public class UserWithChat extends Model<UserWithChat> {
    @TableId(value = "objectId",type = IdType.ASSIGN_ID)
    private String objectId;
    @TableField(fill = FieldFill.INSERT_UPDATE,value = "loginTime")
    private LocalDateTime loginTime;
    @TableField("email")
    private String email;
    @TableField("password")
    private String password;
    @TableField("relName")
    private String relName;
    @TableField("phone")
    private String phone;
    @TableField("genderId")
    private Integer genderId = 2;
    @TableField("name")
    private String name;
    @TableField(fill = FieldFill.INSERT,value = "updatedAt")
    private LocalDateTime updatedAt;
    @TableField(fill = FieldFill.INSERT_UPDATE,value = "createdAt")
    private LocalDateTime createdAt;
    @TableField("uid")
    private String uid;
    @TableField("def")
    private Boolean def = true;

    public String getLoginTime() {
        return loginTime != null ? loginTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) : null;
    }
}
